Page({
  data: {
    currentPage: 0,
    pageSize: 4,
    visitList: [],
    status: ['已失效', '生效中'],
    statusColor: ['cancel', 'success'],
    pageTotal: 1,
    loading: false,
  },
  onLoad() {
    this.getvisitList()
  },
  async getvisitList() {
    if (++this.data.currentPage <= this.data.pageTotal && !this.data.loading) {
      this.setData({
        loading: true,
      })
      const { data } = await wx.http.get(`/visitor?current=${this.data.currentPage}&pageSize=${this.data.pageSize}`)
      console.log(data)
      this.setData({
        visitList: data.rows,
        pageTotal: data.pageTotal,
        loading: false,
      })
    }
  },
  onReachBottom() {
    this.getvisitList()
  },
  goPassport(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/visitor_pkg/pages/passport/index?id=${id}`,
    })
  },
})
